import csv
import random

# List of real disease names in English
real_disease_names = [
    "Common Cold", "Influenza", "Pneumonia", "Bronchitis", "Asthma",
    "Hypertension", "Coronary Heart Disease", "Diabetes", "Gastric Ulcer",
    "Gastritis", "Gallstones", "Cholecystitis", "Hepatitis", "Nephritis",
    "Arthritis", "Gout", "Cervical Spondylosis", "Lumbar Disc Herniation",
    "Migraine", "Neurasthenia", "Depression", "Anxiety Disorder",
    "Obsessive - Compulsive Disorder", "Cataract", "Glaucoma", "Otitis Media",
    "Sinusitis", "Tonsillitis", "Appendicitis", "Hemorrhoids", "Eczema",
    "Urticaria", "Psoriasis", "Vitiligo", "Anemia", "Leukemia",
    "Thyroid Nodule", "Hyperthyroidism", "Hypothyroidism",
    "Alzheimer's Disease", "Parkinson's Disease", "Cerebral Infarction",
    "Cerebral Hemorrhage", "Myocardial Infarction", "Arrhythmia",
    "Hyperlipidemia", "Obesity", "Sleep Apnea Hypopnea Syndrome",
    "Herpes Zoster", "Scarlet Fever", "Chickenpox", "Hand, Foot and Mouth Disease",
    "Mumps", "Measles", "Rubella", "Whooping Cough", "Tetanus", "Rabies",
    "Acquired Immunodeficiency Syndrome (AIDS)", "Syphilis", "Gonorrhea",
    "Condyloma Acuminata", "Genital Herpes", "Chronic Obstructive Pulmonary Disease (COPD)",
    "Pulmonary Fibrosis", "Pulmonary Embolism", "Pneumothorax", "Pleural Effusion",
    "Heart Failure", "Cardiomyopathy", "Valvular Heart Disease",
    "Congenital Heart Disease", "Ulcerative Colitis", "Crohn's Disease",
    "Irritable Bowel Syndrome", "Constipation", "Diarrhea", "Anal Fistula",
    "Anal Fissure", "Rectal Prolapse", "Urethritis", "Cystitis",
    "Prostatitis", "Benign Prostatic Hyperplasia", "Epididymitis",
    "Seminal Vesiculitis", "Orchitis", "Breast Hyperplasia", "Mastitis",
    "Breast Cancer", "Ovarian Cyst", "Uterine Fibroid",
    "Endometriosis", "Cervical Cancer", "Ovarian Cancer",
    "Irregular Menstruation", "Dysmenorrhea", "Amenorrhea",
    "Polycystic Ovary Syndrome", "Menopausal Syndrome",
    "Osteoporosis", "Bone Tumor", "Fracture", "Dislocation",
    "Tendinitis", "Synovitis", "Frozen Shoulder", "Tennis Elbow",
    "Tendinitis", "Achilles Tendinitis", "Sciatica", "Trigeminal Neuralgia",
    "Facial Neuritis", "Myasthenia Gravis", "Epilepsy",
    "Multiple Sclerosis", "Systemic Lupus Erythematosus",
    "Rheumatoid Arthritis", "Sjögren's Syndrome", "Ankylosing Spondylitis",
    "Dermatomyositis", "Scleroderma", "Allergic Purpura",
    "Idiopathic Thrombocytopenic Purpura", "Hemophilia", "Thalassemia",
    "Aplastic Anemia", "Paroxysmal Nocturnal Hemoglobinuria",
    "Malignant Lymphoma", "Myeloma", "Hodgkin's Lymphoma",
    "Non - Hodgkin's Lymphoma", "Esophageal Cancer", "Gastric Cancer",
    "Colon Cancer", "Rectal Cancer", "Liver Cancer", "Pancreatic Cancer",
    "Bile Duct Cancer", "Gallbladder Cancer", "Lung Cancer", "Kidney Cancer",
    "Bladder Cancer", "Prostate Cancer", "Testicular Cancer", "Penile Cancer",
    "Choriocarcinoma", "Hydatidiform Mole", "Invasive Hydatidiform Mole"
]


def dic_gen():
    """
    Generate a dictionary table containing disease codes and names.
    :return: A list of dictionaries containing disease codes and names.
    """
    diseases = []
    for i in range(200):
        # Generate a disease code in the format 'D001' to 'D200'
        disease_code = f"D{i + 1:03d}"
        # Randomly select a real disease name
        disease_name = random.choice(real_disease_names)
        disease_dict = {
            "Disease Code": disease_code,
            "Disease Name": disease_name
        }
        diseases.append(disease_dict)
    return diseases


if __name__ == "__main__":
    # Call the function to generate the disease information list
    disease_list = dic_gen()

    # Define the field names for the CSV file
    fieldnames = ["Disease Code", "Disease Name"]

    # Open the file and write the data
    with open('disease_dict.csv', mode='w', newline='', encoding='utf-8-sig') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        # Write the header
        writer.writeheader()

        # Write each row of data
        for disease in disease_list:
            writer.writerow(disease)

    print("The disease dictionary table has been saved to disease_dict.csv.")